package br.projecao.laboratorio.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author edson.sousa
 */
public class DAO {

  protected String url = "jdbc:mysql://localhost:3306/edsonmateus?autoReconnect=true";
  protected String usuario = "root";
  protected String senha = "mysql";

  protected String driver = "com.mysql.jdbc.Driver";
  protected Connection conexao = null;

  protected void abreConexao() throws SQLException {
    try {
      Class.forName(driver);
      conexao = DriverManager.getConnection(url, usuario, senha);
    } catch (Exception e) {
      throw new SQLException(e.getMessage());
    }
  }

  protected void fechaConexao() {
    try {
      if (conexao != null) {
        conexao.close();
        conexao = null;
      }
    } catch (SQLException e) {
      //
    }

  }
}
